a = 'abc'
b = 'cbc'

def fun(a: str, b: str) -> bool:
    if len(a) != len(b):
        return False
    res = {}
    for v_b in b:
        res[v_b] = res.get(v_b, 0) + 1
    for v_a in a:
        v_a_num = res.get(v_a)
        if not v_a_num:
            return False
        res[v_a] = v_a_num - 1
        if res[v_a] == 0:
            res.pop(v_a)
    return res == {}

print(fun(a, b))
